import java.util.*;

public class _冰雹数 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int x = scanner.nextInt();
        System.out.println(func(x));
    }


    public static long func(int x) {
        long max = 0;
        for (int i = 1; i <= x; i++) {
            long tmp = i;
            while (tmp != 1) {
                if (tmp % 2 == 0) {
                    tmp = tmp / 2;
                } else {
                    tmp = tmp * 3 + 1;
                }
                if (tmp > max) {
                    max = tmp;
                }
            }
        }
        return max;
    }
}
